<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<jsp:include page="/comm/header.jsp" />
<jsp:include page="/comm/menu.jsp" />
<script type="text/javascript">
<!--
	
	function textTrim(str){
		var reg = /^\s+|\s+$/g;
		return str.replace(reg, "");
	}
	
	var doSubmit = function(){
		if(validEmail()){
			document.form1.action = "retrievepwd.htm";
			document.form1.submit(); 
		}
	};
	
	$(function(){
		$("#mail").blur(validEmail);
		$("#retrieve").click(doSubmit);
		
		$("#mail").bind('keyup',function(event) {
			if(event.keyCode==13){
				doSubmit();
			}
		});
		
	});
	
	var isSameEmail = function(mail){
		var flag = false;
		$.ajax({
  			type:"POST",
  			url:"isSameEmail.htm",
  			async: false,
  			data:{email:mail},
  			datatype:"text",
  			success:function(data){
  				if(data == "true"){
  					$("#mailTip").html("<img src='<%=path%>/images/yes.gif'/>");
  					flag = true;
  				}else{
  					$("#mailTip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>对不起，此邮箱不存在，请重新输入!</font>");
  				}
  		    }	
  		});	
		return flag;
	};
	
	var	validEmail = function(){
		var mail = $("#mail").val();
		mail = textTrim(mail);
		$("#mail").val(mail);
		if($("#mail").val()){
		  	var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
		  	if(reg.test(mail)){
	  			return isSameEmail(mail);
		  	}else{
		  		$("#mailTip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>请输入有效的邮箱地址</font>");
		  		return false;
		  	}
		}
	};
	
//-->
</script>

<div class="clear"></div>

<!--第1部分开始  --> 
    <div class="wrap1">
    	<div class="blank1"></div>
        
    	<div class="outbox3">
        	<div class="tab7_tt">忘记密码</div>
        	<div class="pbox4">
        		<form name="form1" method="post">
            	<div style=" margin:10px 0">请填写您的Email地址：<input id="mail" name="userModel.email" type="text" class="input1" size="41"/><span id="mailTip"></span></div>
				<div class="tips1"><span>您的邮箱将收到一封认证确认邮件，请查收。点击邮件中的确认链接即可通过邮箱认证。</span></div>
            	<div class="login_but" style="text-align:center; margin:20px 0"><input type="button" class="login" id="retrieve" value="下一步" style="cursor:pointer"/></div>
            	</form>
            </div>

      	</div>

    </div>
<!--第1部分结束  --> 
<jsp:include page="/comm/bottom.jsp" />
